package cn.harry.cabinet.server.dto.feature

import kotlinx.serialization.InternalSerializationApi
import kotlinx.serialization.Serializable

 /**
 * 特征上传请求
 */
@Serializable
@InternalSerializationApi
data class FeatureUploadRequest(
    val name: String,           // 用户名称
    val imageBase64: String     // Base64编码的图片数据
) {
    fun isValid(): Boolean {
        return name.isNotBlank() && imageBase64.isNotBlank()
    }

    fun getValidationErrors(): List<String> {
        val errors = mutableListOf<String>()
        if (name.isBlank()) errors.add("用户名称不能为空")
        if (imageBase64.isBlank()) errors.add("图片数据不能为空")
        return errors
    }
}

/**
 * 批量特征上传请求
 */
@Serializable
@InternalSerializationApi
data class BatchFeatureUploadRequest(
    val features: List<FeatureUploadRequest>
) {
    fun isValid(): Boolean {
        return features.isNotEmpty() && features.all { it.isValid() }
    }
}

/**
 * 特征上传响应
 */
@Serializable
@InternalSerializationApi
data class FeatureUploadResponse(
    val name: String,
    val success: Boolean,
    val message: String,
    val imagePath: String? = null,
    val featurePath: String? = null
)

/**
 * 批量上传响应
 */
@Serializable
@InternalSerializationApi
data class BatchFeatureUploadResponse(
    val totalCount: Int,
    val successCount: Int,
    val failCount: Int,
    val results: List<FeatureUploadResponse>
)

/**
 * 特征列表项
 */
@Serializable
@InternalSerializationApi
data class FeatureListItem(
    val name: String,
    val time: Long,
    val hasImage: Boolean,
    val imagePath: String? = null
)

/**
 * 特征列表响应
 */
@Serializable
@InternalSerializationApi
data class FeatureListResponse(
    val features: List<FeatureListItem>,
    val totalCount: Int
)
